package org.ht.entity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;

public abstract class AbstractEntity {
	public ArrayList<ChildEntity> children = new ArrayList<ChildEntity>();

	/**
	 * 根据有序的key,返回有序的value 这里仅返回那些可以在大表中显示的表的属性
	 */
	public ArrayList<String> getPlainPropertyValue(List<String> key) {
		ArrayList<String> value = new ArrayList<String>();
		HashMap<String, String> allMap = new HashMap<String, String>();
		// 先合并子对象的所有属性值
		for (ChildEntity child : children) {
			if (child.isPlainPropertyContainer() == true) {
				allMap.putAll(child.property);
			}
		}
		for (String kname : key) {
			value.add(allMap.get(kname));
		}
		return value;
	}

	public Vector<String> getPropertyValueByVector(List<String> key) {
		Vector<String> value = new Vector<String>();
		value.addAll(getPlainPropertyValue(key));
		return value;
	}

	public HashMap<String, String> getProperty() {
		HashMap<String, String> allMap = new HashMap<String, String>();
		// 合并子对象的所有属性值
		for (ChildEntity child : children) {
			allMap.putAll(child.property);
		}
		return allMap;
	}
}
